#include <string>

using namespace std;
class Solution {
public:
  string mergeAlternately(string word1, string word2) {
    string ret;
    auto it1 = 0;
    auto it2 = 0;
    while (it1 != word1.size() && it2 != word2.size()) {
      ret += word1[it1++];
      ret += word2[it2++];
    }
    if (it1 != word1.size()) {
      ret += word1.substr(it1, word1.size() - it1);
    }
    if (it2 != word2.size()) {
      ret += word2.substr(it2, word2.size() - it2);
    }
    return ret;
  }
};